from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware

from controller.AiController import app as ai_router

app = FastAPI(title="AI项目后端", description="中医理疗馆AI助手后端服务")

# 注册AI路由
app.include_router(ai_router)

# 添加CORS中间件
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # 开发环境可以允许所有源，生产环境要指定具体域名
    allow_credentials=False,
    allow_methods=["*"],  # 允许所有HTTP方法
    allow_headers=["*"],  # 允许所有头部
)
@app.get("/")
async def root():
    return {"message": "AI项目后端服务运行中"}

@app.get("/health")
async def health_check():
    return {"status": "healthy", "message": "服务正常"}

@app.get("/hello/{name}")
async def say_hello(name: str):
    return {"message": f"Hello {name}"}
